package com.yw.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yw.columnInfo.domain.Column;
import com.yw.mapper.ColumnMapper;
import com.yw.service.ColumnService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class ColumnServiceImpl extends ServiceImpl<ColumnMapper, Column>
                                implements ColumnService {


    @Override
    //根据目录id查询每个目录下面的栏目
    public List<String> getAllColumnByContentsId(Integer id){
        LambdaQueryWrapper<Column> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Column::getContentsId,id);
        List<Column> list = this.list(wrapper);
        ArrayList<String> strList = new ArrayList<>();
        for (Column column : list) {
            strList.add(column.getColumnName());
        }
        return strList;
    }
}
